const {CleanWebpackPlugin} = require('clean-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const path = require('path');
const { Module } = require('webpack');
const isProd = process.env.NODE_ENV === "production";
function resolve(dir){
    return path.resolve(__dirname,dir);
}
Module.exports = {
    mode: isProd ? "production" : "development",
    entry:{
        app:resolve('./src/main.ts')
    },
    output:{
        path:resolve('dist'),
        filename:'[name].[contenthash:8].js'
    },
    module:{
        rules:[
            {
                test:/\.([cm]?ts|tsx)$/,
                use:'ts-loader',
                include:[resolve('src')]
            }
        ]
    },
    Plugins:[
        new CleanWebpackPlugin({}),
        new HtmlWebpackPlugin({
            template:'./public/index.html'
        })
    ],
    resolve:{
        extensions:['.ts','.tsx','.js']
    },
    devServer:{
        open:true,
        prot:8083
    }
}